package com.sniper.utils;

import org.apache.commons.lang3.ArrayUtils;

/**
 * Created by suzhen on 2017/8/7.
 */
public class PostUtil {
    /**
     * 丛路径中读取图片地址
     *
     * @param files
     * @return
     */
    public static BackImg getImg(String[] files) {
        if (files != null && ArrayUtils.isNotEmpty(files)) {
            for (String _f : files) {
                if (_f.contains("image")) {
                    int start = _f.indexOf(":") + 1;
                    String id = _f.substring(_f.indexOf(":") + 1, _f.indexOf(":", start));
                    String url = _f.substring(_f.lastIndexOf(":") + 1);
                    return new BackImg(id, url);
                }
            }
        }

        return null;
    }

    public static class BackImg {
        private String id;
        private String url;

        BackImg(String id, String url) {
            this.id = id;
            this.url = url;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }

}
